#ifndef __FPSCALCULATOR_H__
#define __FPSCALCULATOR_H__

#pragma once
#include "pch.h"

class FpsCalculator :public std::enable_shared_from_this<FpsCalculator>
{
public:
	void Add();
	float Fps();
	std::string Name();
	void SetName(std::string s);
	~FpsCalculator();
	FpsCalculator() = default;

	void Reset();

	void Init(int size = 100, std::string name = "", bool managed = false);

private:
	std::queue<std::chrono::high_resolution_clock::time_point> cache;
	std::string name = "";
	bool managed = false;

protected:
	int size = 100;

};


class FpsManager
{
public:
	SINGLETON_DEFINE(FpsManager);
	void AddCalculator(std::shared_ptr<FpsCalculator> calculator);
	void Remove(std::string name);
	void Remove(std::shared_ptr<FpsCalculator> calculator);
	std::string Dump();
	~FpsManager();

private:
	FpsManager() = default;
	std::list<std::shared_ptr<FpsCalculator>> vec_calculators;
	std::mutex mtx;
};
#endif // __FPSCALCULATOR_H__